import sys
import os
import re

"""
删除字符串中重复次数最少的字符
"""
class Solution:
    def delMinFrequencyChar(self, input):

        def parse(string):
            mmap = {}
            for ch in string:
                if ch not in mmap:
                    mmap[ch] = 1
                else:
                    mmap[ch] +=1
            min_ = min(list(mmap.values()))
            # print("min_", min_)
            # print("mmap", mmap)
            new_string = []
            for ch in string:
                if mmap[ch] != min_:
                    new_string.append(ch)
            return ''.join(new_string)

        
        outlist = []
        for item in input:
            out = parse(item)
            # print("out", out)
            outlist.append(out)
        # Write Code Here 
        return outlist

_input_cnt = 0
_input_cnt = int(input())
_input_i = 0
_input = []
while _input_i < _input_cnt:
    try:
        _input_item = input()
    except:
        _input_item = None
    _input.append(_input_item)
    _input_i+=1
  
s = Solution()
res = s.delMinFrequencyChar(_input)
print("\n")
for res_cur in res:
    print(str(res_cur) + "\n")